package com.chao.tlias.service.impl;

import com.chao.tlias.Pojo.PageBean;
import com.chao.tlias.Pojo.clazz;
import com.chao.tlias.mapper.ClazzMapper;
import com.chao.tlias.service.ClazzService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class ClazzServiceImpl implements ClazzService {

    @Autowired
    private ClazzMapper clazzMapper;

    @Override
    public PageBean page(Integer page, Integer pageSize, String name, LocalDate begin, LocalDate end) {
        PageHelper.startPage(page,pageSize);

        List<clazz> clazzList = clazzMapper.list(name, begin, end);
        Page<clazz> p = (Page<clazz>) clazzList;

        PageBean pageBean = new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }
}
